const app = require('./app')
const config = require('./config/config')

const PORT = config.port

const server = app.listen(PORT, () => {
  console.log('=================================')
  console.log('🚀 京东商城后端服务启动成功')
  console.log(`📡 服务地址: http://localhost:${PORT}`)
  console.log(`⏰ 启动时间: ${new Date().toLocaleString('zh-CN')}`)
  console.log('=================================')
})

// 优雅关闭
process.on('SIGTERM', () => {
  console.log('收到SIGTERM信号，正在关闭服务器...')
  server.close(() => {
    console.log('服务器已关闭')
    process.exit(0)
  })
})

process.on('SIGINT', () => {
  console.log('\n收到SIGINT信号，正在关闭服务器...')
  server.close(() => {
    console.log('服务器已关闭')
    process.exit(0)
  })
})











